/**
 * 
 * @param {Number} type 1是年月日,2是年月日时分秒 
 * @returns 1返回YYYY-MM-DD 2返回YYYY-MM-DD HH:MM:SS
 */
const dataFormat = (type) => {
    const date = new Date();
    const y = date.getFullYear();
    const m = date.getMonth() + 1;
    const d = date.getDate();
    const YYYYMMDD=y+"-"+m+"-"+d;
    if(type===1){
        return YYYYMMDD;
    }else if(type===2){
        const h = date.getHours();
        const min = date.getMinutes();
        const s = date.getSeconds();
        return YYYYMMDD+" "+h+":"+min+":"+s
    }else{}
}
module.exports=dataFormat;
